#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using XcoAppSpaces.Contracts.Service;

namespace XcoAppSpaces.Contracts.Serialization
{
	/// <summary>
	/// Interface definition for classes used for serialization and deserialization of 
	/// objects (used for remote communication and for serialized data storage).
	/// </summary>
	public interface IXcoSerializer : IXcoService
	{
	    /// <summary>
		/// Serializes an object into a byte array.
		/// </summary>
		/// <param name="element">The object to be serialized.</param>
		/// <returns>The serialized object.</returns>
		byte[] Serialize(object element);

		/// <summary>
		/// Deserializes an object from a byte array.
		/// </summary>
		/// <param name="element">The serialized object.</param>
		/// <returns>The object that has been deserialized.</returns>
		object Deserialize(byte[] element);

		/// <summary>
		/// Checks if the given type can be serialized. This method is called for every
		/// message type in the worker contract when connecting to a worker, so that any
		/// exceptions due to potential serialization problems can be thrown to the user.
		/// </summary>
		/// <param name="type">The type to be checked.</param>
		/// <param name="errorInfo">Contains information about serialization problems, if the type cannot be serialized.</param>
		/// <returns>True if the type can be serialized, otherwise false.</returns>
		bool CanTypeBeSerialized(Type type, out string errorInfo);
	}
}
